package juc.day03;

import java.util.concurrent.*;

public class MyThreadPoolDemo {
    public static void main(String[] args) {
        ExecutorService threadPool = new ThreadPoolExecutor(
                2,
                5,
                3L,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(3),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardPolicy()
//                new ThreadPoolExecutor.DiscardOldestPolicy()
                // new ThreadPoolExecutor.CallerRunsPolicy()
                // new ThreadPoolExecutor.AbortPolicy()
        );

        for(int i=1;i<=20;i++){
            int finalI = i;
            threadPool.execute(()->{
                    System.out.println(Thread.currentThread().getName()+"号业务员办理业务"+ finalI);
                });
        }
    }
}
